<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        h1 {
            text-align: center;
            color: red
        }

        #p {
            font-size: 20px;
            margin-left: 30px;
        }
    </style>
</head>

<body>
    <div id="con">
        <h1 id="h1"></h1>
        <p id="p"></p>
    </div>
</body>
<script src="../js/ajax.js"></script>
<script>
    var queryString = location.search;
    var q = queryString.slice(1);
    var qs = q.split('=');
    var textData = {};
    myAjax("post", "http://www.qhdlink-student.top/student/newsinfo.php", "username=zyp&userpwd=123456&userclass=70&type=4&m=" + qs[1] + "", xiangqing)
    function xiangqing(data) {
        textData = data;
    }
    function look_xw(data) {
        for (var key in data) {
            var h = document.createElement('h1');
            var p = document.createElement('p');
            h.innerHTML = data[key].title_news;
            p.innerHTML = data[key].info_news

            document.getElementById('con').appendChild(h);
            document.getElementById('con').appendChild(p);
        }
    }
    setTimeout(function () {
        look_xw(textData);
    }, 500)

    if (localStorage.getItem("textsData") != null) {
        var textsData = JSON.parse(localStorage.getItem("textsData"));
    }
    var title;
    var info;
    var xwid = qs[1];//将querystring的m参数给xwid
    if (xwid.length > 2) {
        for (var x in textsData) {
            if (xwid == textsData[x].id_news) {
                // console.log(textsData[x].id_news)
                title = textsData[x].title_news;
                info = textsData[x].info_news;
            }
        }
        document.getElementById('h1').innerHTML = title;
        document.getElementById('p').innerHTML = info;
    }

</script>


</html>